import router from "@/router";
import NProgress from 'nprogress'
import {getUserInfo} from "@/utils/localStorage.ts";
import userStore from "@/pinia/userStore.ts";

router.beforeEach((to, from, next) => {
    NProgress.start()
    const userInfo = getUserInfo()
    if (userInfo.token) {
        next()
    } else {
        if (to.path === "/hospital/booking") {
            const userstore = userStore()
            userstore.changeDialog(true)
            NProgress.done()
        } else {
            next()
        }
    }
})


router.afterEach((to, from) => {
    NProgress.done()
})
